package top.fangw.admin.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import top.fangw.admin.pojo.entity.SysApplication;
import top.fangw.admin.mapper.SysApplicationMapper;
import top.fangw.admin.service.ISysApplicationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.fangw.common.api.vo.InitTenantApplication;
import top.fangw.common.mybatis.annotation.DyDataSource;

/**
 * <p>
 * 用途：存储各个应用信息 服务实现类
 * </p>
 *
 * @author fangw
 * @since 2024-03-02
 */
@Service
@DS("base_info")
public class SysApplicationServiceImpl extends ServiceImpl<SysApplicationMapper, SysApplication> implements ISysApplicationService {

    @Override
    @DyDataSource(tenantId = "#initTenantApplication.tenantId", autoTenantId = false)
    public void initTenantApplication(InitTenantApplication initTenantApplication) {
        initTenantApplication.getApplicationVoList().stream().map(item -> new SysApplication().build(item)).forEach(this::save);
    }
}
